/**
 * [DragonApp.view.notice.Image description]
 * 图像公告新建及编辑窗体
 */
Ext.define('DragonApp.view.notice.Image', {
    extend: 'Ext.window.Window',

    alias: 'widget.notice-image-window',

    requires: [
        'DragonApp.view.pub.combobox.Tag',
        'DragonApp.view.notice.ImageController'
    ],

    controller: 'noticeimagegrid',

    layout: 'container',
    resizable: false,
    closable: true,
    modal: true,

    items: [{
        xtype: 'form',
        padding: 10,
        modelValidation: true,
        layout: {
            type: 'fit',
            align: 'stretch'
        },
        items: [{
                xtype: 'fieldset',
                width: 1118,
                title: '公告信息',
                layout: 'anchor',
                padding: '15 20 15 20',
                defaults: {
                    afterLabelTextTpl: DragonApp.util.String.required,
                    anchor: '100%',
                    xtype: 'textfield',
                    msgTarget: 'side',
                    labelWidth: 75
                },
                items: [{
                        xtype: 'hiddenfield',
                        fieldLabel: '公告ID',
                        name: 'id'
                    },
                    {
                        xtype: 'fieldcontainer',
                        layout: 'hbox',
                        defaults: {
                            afterLabelTextTpl: DragonApp.util.String.required,
                            anchor: '100%',
                            xtype: 'textfield',
                            msgTarget: 'side',
                            labelWidth: 75
                        },
                        items: [{
                                xtype: 'datetimefield',
                                fieldLabel: '开始时间',
                                margin: '0 12 0 0',
                                allowBlank: false,
                                name: 'begintime',
                                labelWidth: 75
                            },
                            {
                                xtype: 'datetimefield',
                                fieldLabel: '结束时间',
                                margin: '0 12 0 0',
                                allowBlank: false,
                                labelWidth: 75,
                                name: 'endtime'
                            },
                            {
                                xtype: 'multichannelcombo',
                                fieldLabel: '适用渠道',
                                margin: '0 12 0 0',
                                allowBlank: false,
                                labelWidth: 75,
                                name: 'channel'
                            },
                            {
                                xtype: 'tagcombobox',
                                width: 270,
                                labelWidth: 75,
                                editable: false,
                                allowBlank: false,
                                fieldLabel: '选择标签',
                                forceSelection: true,
                                name: 'tag',
                                emptyText: '请选择'
                            },
                            {
                                xtype: 'hiddenfield',
                                fieldLabel: '公告类型',
                                name: 'type',
                                value: 1
                            },
                            {
                                xtype: 'hiddenfield',
                                fieldLabel: '表单类型',
                                name: 'formtype',
                                itemId: 'formtype'
                            }
                        ]
                    }
                ]
            },
            {
                xtype: 'container',
                layout: 'container',
                items: [{
                    xtype: 'imagegrid',
                    title: '图库列表',
                    hidden: true,
                    height: 255
                }, {
                    xtype: 'selectedgrid',
                    title: '公告图片',
                    height: 400
                }]
            }
        ]
    }],
    dockedItems: [{
        xtype: 'toolbar',
        dock: 'bottom',
        ui: 'footer',
        layout: {
            pack: 'end',
            type: 'hbox'
        },
        items: [{
            xtype: 'button',
            text: '取消',
            itemId: 'imgResetBtn',
            iconCls: 'x-fa fa-undo',
            listeners: {
                click: function() {
                    this.up('window').down('form').getForm().reset();
                    var selectgrid = Ext.ComponentQuery.query('selectedgrid')[0];
                    var store = selectgrid.getStore();
                    store.removeAll();
                }
            }
        },{
            xtype: 'button',
            text: '发布',
            iconCls: 'x-fa fa-check',
            listeners: {
                click: 'onSubmit'
            }
        }]
    }]
});